package com.kingyun.gpsinspection.purificationservice.services.jsm.innerservice.impl.jobpost;

import com.kingyun.gpsinspection.purificationservice.dao.mapper.jsm.PostMapper;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.jsm.PostTypeMapper;
import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.PostType;
import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.postVo;
import com.kingyun.gpsinspection.purificationservice.facade.service.jsm.post.JsmPostTypeService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zmling on 2017/1/3.
 * 岗位类型信息
 */

public class JsmPostTypeServiceImpl implements JsmPostTypeService {
    @Autowired
    private PostTypeMapper postTypeMapper;
    @Autowired
    private PostMapper postMapper;

    /**
     * 查询岗位类型所有信息
     *
     * @param postType
     * @return
     */
    @Override
    public List<PostType> findPostTypeList(String postType) {

        return postTypeMapper.selectByPrimaryKey(postType);
    }

    /**
     * 查询岗位类型所有信息
     *
     * @param postType
     * @param depId
     * @param postId
     * @return
     */
    @Override
    public List<PostType> findPostTypeList(String postType, String depId, String postId) {
        List<postVo> pList = postMapper.findPostByDepId(depId);
        List<String> strlist = null;
        if (pList != null && pList.size() > 0) {
            strlist = new ArrayList<String>();
            for (postVo pv : pList) {
                if (pv.getPostId().equals(postId)) {
                    continue;
                }
                strlist.add(pv.getPostName());
            }
        }
        PostType pt = new PostType();
        pt.setPostType(Short.valueOf(postType));
        if (strlist != null && strlist.size() > 0) {
            pt.setList(strlist);
        }
        List<PostType> list = postTypeMapper.selectByNotPostTypeId(pt);
        return list;
    }

    /**
     * 通过组织机构id查询
     *
     * @param orgId
     * @return
     */
    @Override
    public List<postVo> findListPostByOrgId(String orgId) {
        return postMapper.findListPost(orgId);
    }

    /**
     * @param postId 岗位Id
     */
    @Override
    public postVo findPostVoPostId(String postId) {

        return null;
    }
    /**
     * 根据条件查询岗位类型信息
     *
     * @param record
     * @return
     */
    @Override
    public List<PostType> selectByPostTypeId(PostType record) {
        return postTypeMapper.selectByPostTypeId(record);
    }
}
